<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>选择地图</title>
    <style>
        html, body, #viewDiv {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }
    </style>
    <link rel="stylesheet" href="https://js.arcgis.com/4.16/esri/themes/light/main.css">
    <script src="https://js.arcgis.com/4.16/"></script>
    <script>
        require([
            "esri/Map",
            "esri/views/MapView",
            "esri/widgets/BasemapToggle",
            "esri/widgets/BasemapGallery"
        ], function(Map, MapView, BasemapToggle, BasemapGallery) {

            var map = new Map({
                basemap: "streets-navigation-vector"
            });

            var view = new MapView({
                container: "viewDiv",
                map: map,
                center: [104, 30],
                zoom: 18
            });
            // basemapToggle
            var basemapToggle = new BasemapToggle({
                view: view,
                nextBasemap: "satellite"
            });

            view.ui.add(basemapToggle, "bottom-right");
            // basemapGallery
            var basemapGallery = new BasemapGallery({
                view: view,
                container: basemapGalleryDiv
              //  source: {
              //      portal: {
                //        url: "https://www.arcgis.com",
                 //       useVectorBasemaps: true // Load vector tile basemaps
                  //  }
               // }
            });

            view.on("click", function(event){
                // event is the event handle returned after the event fires.
                console.log(event.mapPoint);

                //切换地图
                basemapToggle.toggle();

            });

        //    view.ui.add(basemapGallery, "top-right");

        });
    </script>
</head>
<body>
<div id="viewDiv"></div>
<div id="basemapGalleryDiv"></div>
</body>
</html>




























































